Declare Function SystemParametersInfo Lib "User" (ByVal uAction As Integer, ByVal uparam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
Declare Function WriteProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String) As Integer
Declare Function GetProfileInt Lib "Kernel" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Integer) As Integer
Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
Const SPIF_UPDATEINIFILE = &H1
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_SENDWININICHANGE = &H2
Sub Command1_Click ()
'Assign the filename of the wallpaper you want to use
filename$ = "c:\windows\castle.bmp"
'Change the wallpaper
X% = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, filename$, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
'Wait for Windows to process change and update win.ini